package com.sina.weibo.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.text.SpannableString;
import android.text.TextPaint;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import com.sina.weibo.RPCHelper;
import com.sina.weibo.Utils;
import com.sina.weibo.models.Message;
import java.io.File;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;

public class MessageListItemView extends LinearLayout
  implements MainListItemView
{
  private static Map<String, ListView> downloading = new Hashtable();
  private Context context;
  private String mCacheDir;
  private TextView mContent;
  private TextView mDate;
  private TextView mName;
  private ImageView mPortrait;
  private int mReadMode;
  private TextView mSubContent;
  public Message message;
  private ListView parent;

  public MessageListItemView(Context paramContext, ListView paramListView, Message paramMessage, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, int paramInt)
  {
    super(paramContext);
    this.context = paramContext;
    this.parent = paramListView;
    String str = paramContext.getCacheDir().getAbsolutePath();
    this.mCacheDir = str;
    View localView = ((LayoutInflater)paramContext.getSystemService("layout_inflater")).inflate(2130903057, this);
    TextView localTextView1 = (TextView)findViewById(2131623996);
    this.mName = localTextView1;
    TextView localTextView2 = (TextView)findViewById(2131624022);
    this.mDate = localTextView2;
    TextView localTextView3 = (TextView)findViewById(2131623998);
    this.mContent = localTextView3;
    TextView localTextView4 = (TextView)findViewById(2131624026);
    this.mSubContent = localTextView4;
    ImageView localImageView = (ImageView)findViewById(2131623993);
    this.mPortrait = localImageView;
    this.mReadMode = paramInt;
    MessageListItemView localMessageListItemView = this;
    Message localMessage = paramMessage;
    boolean bool1 = paramBoolean1;
    boolean bool2 = paramBoolean2;
    int i = paramInt;
    localMessageListItemView.update(localMessage, bool1, bool2, 0, i);
  }

  private void displayDefaultPortrait()
  {
    ImageView localImageView = this.mPortrait;
    Context localContext = this.context;
    Bitmap localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(this.context.getResources(), 2130838011));
    Bitmap localBitmap2 = Utils.outputBmp(localContext, localBitmap1, 0);
    localImageView.setImageBitmap(localBitmap2);
  }

  public void update(Object paramObject, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, int paramInt)
  {
    Message localMessage = (Message)paramObject;
    this.message = localMessage;
    String str2;
    label75: String str3;
    if (paramBoolean3)
    {
      TextView localTextView1 = this.mDate;
      int i = getResources().getColor(2131230720);
      localTextView1.setTextColor(i);
      Context localContext = this.context;
      Date localDate = localMessage.time;
      String str1 = Utils.formatDate(localContext, localDate);
      if (localMessage.num != 0)
        break label253;
      str2 = "";
      TextView localTextView2 = this.mName;
      StringBuilder localStringBuilder = new java/lang/StringBuilder;
      if ((localMessage.type != 1) || (localMessage.num != 0))
        break label287;
      str3 = getResources().getString(2131427445);
      label114: String str4 = String.valueOf(str3);
      localStringBuilder.<init>(str4);
      String str5 = str2;
      localTextView2.setText(str5);
      this.mName.getPaint().setFakeBoldText(1);
      this.mDate.setText(str1);
      String str6 = localMessage.content;
      SpannableString localSpannableString = new SpannableString(str6);
      Utils.highlightContent(getContext(), localSpannableString);
      TextView localTextView3 = this.mContent;
      TextView.BufferType localBufferType = TextView.BufferType.SPANNABLE;
      localTextView3.setText(localSpannableString, localBufferType);
      this.mContent.setVisibility(0);
      if (this.mReadMode != 1)
        break label297;
      this.mPortrait.setVisibility(8);
    }
    while (true)
    {
      return;
      this.mDate.setTextColor(-7829368);
      break;
      label253: Object[] arrayOfObject = new Object[1];
      Integer localInteger = Integer.valueOf(localMessage.num);
      arrayOfObject[0] = localInteger;
      str2 = String.format(" [%d]", arrayOfObject);
      break label75;
      label287: str3 = localMessage.nick;
      break label114;
      label297: this.mPortrait.setVisibility(0);
      if (localMessage.portrait == null)
      {
        displayDefaultPortrait();
        continue;
      }
      displayDefaultPortrait();
      Map localMap1 = downloading;
      String str7 = localMessage.portrait;
      if (localMap1.containsKey(str7))
        continue;
      String str8 = this.mCacheDir;
      String str9 = localMessage.portrait;
      String str10 = Utils.checkCache(str8, str9);
      if (str10 == null)
      {
        Map localMap2 = downloading;
        String str11 = localMessage.portrait;
        ListView localListView = this.parent;
        Object localObject = localMap2.put(str11, localListView);
        LoadPortraitTask localLoadPortraitTask = new LoadPortraitTask(null);
        String[] arrayOfString = new String[1];
        String str12 = localMessage.portrait;
        arrayOfString[0] = str12;
        AsyncTask localAsyncTask = localLoadPortraitTask.execute(arrayOfString);
        continue;
      }
      Bitmap localBitmap1 = BitmapFactory.decodeFile(str10);
      if (localBitmap1 != null)
      {
        ImageView localImageView = this.mPortrait;
        Bitmap localBitmap2 = Utils.outputBmp(this.context, localBitmap1, 0);
        localImageView.setImageBitmap(localBitmap2);
        continue;
      }
      boolean bool = new File(str10).delete();
      displayDefaultPortrait();
    }
  }

  class LoadPortraitTask extends AsyncTask<String, Void, String[]>
  {
    private LoadPortraitTask()
    {
    }

    protected String[] doInBackground(String[] paramArrayOfString)
    {
      String[] arrayOfString = new String[2];
      String str1 = paramArrayOfString[0];
      int i = 0;
      try
      {
        RPCHelper localRPCHelper = RPCHelper.getInstance(MessageListItemView.this.getContext());
        String str2 = MessageListItemView.this.context.getCacheDir().getAbsolutePath();
        String str3 = localRPCHelper.getPicture(str1, str2);
        File localFile = new File(str3);
        if (localFile.exists())
        {
          String str4 = localFile.toString();
          localObject = str4;
        }
        arrayOfString[0] = str1;
        arrayOfString[1] = localObject;
        return arrayOfString;
      }
      catch (Exception localException)
      {
        while (true)
          Object localObject = null;
      }
    }

    protected void onPostExecute(String[] paramArrayOfString)
    {
      String str1 = paramArrayOfString[0];
      String str2 = paramArrayOfString[1];
      ListView localListView;
      Bitmap localBitmap1;
      int k;
      if (str2 != null)
      {
        localListView = (ListView)MessageListItemView.downloading.get(str1);
        localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeFile(str2));
        int i = localListView.getFirstVisiblePosition();
        int j = localListView.getChildCount();
        k = 0;
        if (k >= j)
          Object localObject = MessageListItemView.downloading.remove(str1);
      }
      else
      {
        return;
      }
      if (!(localListView.getChildAt(k) instanceof MessageListItemView));
      while (true)
      {
        k += 1;
        break;
        MessageListItemView localMessageListItemView = (MessageListItemView)localListView.getChildAt(k);
        if (!localMessageListItemView.message.portrait.equals(str1))
          continue;
        if (localBitmap1 != null)
        {
          ImageView localImageView = localMessageListItemView.mPortrait;
          Bitmap localBitmap2 = Utils.outputBmp(MessageListItemView.this.context, localBitmap1, 0);
          localImageView.setImageBitmap(localBitmap2);
          continue;
        }
        MessageListItemView.this.displayDefaultPortrait();
      }
    }

    protected void onPreExecute()
    {
    }

    protected void onProgressUpdate(Void[] paramArrayOfVoid)
    {
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.view.MessageListItemView
 * JD-Core Version:    0.6.0
 */